package com.StarStudio.Mapper;

import com.StarStudio.Domain.Soil;
import org.apache.ibatis.annotations.*;


import java.util.List;

@Mapper
public interface SoilMapper {

    @Select("select s.* from soil s, zone_soil zs where s.soil_id = zs.soil_id and zs.zone_id = #{zoneId}")
    public List<Soil> getAllByZoneId(int zoneId);

    @Select("SELECT * FROM (SELECT s.* FROM soil s, zone_soil zs WHERE s.soil_id = zs.soil_id AND zs.zone_id = #{zoneId}) a ORDER BY soil_id  DESC LIMIT 1")
    public Soil getNewOneByZoneId(int zoneId);

//    @Insert("insert into soil values (null,#{soilTemperature}, #{soilMoisture}, #{soilPh}, #{soilUpdatetime})")
//    @Options(useGeneratedKeys = true)
//    public void add(Soil soil);
//
//    @Update("update soil set soil_temperature=#{soilTemperature},soil_moisture=#{soilMoisture},soil_ph=#{soilPh},soil_updatetime=#{soilUpdatetime} where soil_id = #{soilId}")
//    public void update(Soil soil);
//
//    @Delete("delete from soil where soil_id = #{soilId}")
//    public void delete(int soilId);

}
